<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/jsp/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>security system</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet"
	href="<c:url value="/css/bootstrap.min.css"></c:url>">
<script src="<c:url value="/js/jquery-1.9.1.min.js"></c:url>"></script>
<script src="<c:url value="/js/bootstrap.min.js"></c:url>"></script>
</head>
<body>
	<nav class="navbar navbar-inverse" role="navigation">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header" style="margin:10px;">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="#">UUC Bioengineering Ltd.</a>
		</div>
		<!-- Collect the nav links, forms, and other content for toggling -->
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1" style="margin:10px;">
			<ul class="nav navbar-nav">
				<li><a
					href="<s:url namespace="/security" action="homeAction"/>">Dynamical
						Map</a></li>
				<li><a
					href="<s:url namespace="/security" action="loadLogAction"/>">Access
						Log</a></li>
				<li class="active"><a
					href="<s:url namespace="/security" action="loadErrorReportAction"/>">Error Handle</a></li>
				<li><a
					href="<s:url namespace="/security" action="loadFireReportAction"/>">Fire
						Alarm</a></li>
			</ul>
			<ul class="nav navbar-nav navbar-right" style="margin-right:20px;">
				<li><a href="#">${loginedAdmin.admin_ID}</a></li>
				<li><a href="#">${loginedAdmin.admin_Username}</a></li>
				<li><a href="#">Security Administrator</a></li>
				<li><a
					href='<s:url namespace="/system" action="adminLogout"></s:url>'>Log
						out</a></li>
			</ul>
		</div>
		<!-- /.navbar-collapse -->
	</nav>
	<div class="container">
		<div class="row" style="margin-top:10px;margin-bottom:30px;">
			<s:form action="loadErrorReportAction" method="post"
				namespace="/security">
				<div class="row">
					<div class="col-lg-12 col-lg-offset-3">
						<div class="col-lg-1">
						<label style="font-size:20px;">Status</label>
						</div>
						<div class="col-lg-3 ">
							<s:select cssClass="form-control input-lg"
								name="helper.msg_status" list="#{'0':'Unread','1':'Read'}">
							</s:select>
						</div>
						<div class="col-lg-1 col-lg-offset-1">
							<s:submit value=" Query " style="margin: 5px 0px 15px 10px;"
								cssClass="btn btn-success"></s:submit>
						</div>
					</div>
				</div>
			</s:form>
		</div>
		<div class="row" style="margin-top:20px;">
			<div class="col-lg-12">
				<div class="panel panel-primary">
					<div class="panel-heading">Error Report</div>
					<div calss="panel-content">
						<table class="table table-hover">
							<thead>
								<tr>
									<th>ID</th>
									<th>UserID</th>
									<th>AdminID</th>
									<th>Date</th>
									<th>Content</th>
									<th>Operation</th>
								</tr>
							</thead>
							<tbody>
								<s:iterator value="page.pageContent">
									<tr>
										<td><s:property value="msg_ID" /></td>
										<td><s:property value="sender_ID" /></td>
										<td><s:property value="receiver_ID" /></td>
										<td><s:property value="msg_Date" /></td>
										<td><s:property value="msg_Content" /></td>
										<td style="display: none;"><s:property value="msg_Status" />
										</td>
										<td><button type="submit" class="btn btn-primary"
												onclick="read('<s:property value="msg_ID" />');">Read</button>
										</td>
									</tr>
								</s:iterator>
							</tbody>
						</table>
					</div>
					<div id="pageinfo">
						Total
						<s:property value="page.totalRecNum" />
						Records, Current View
						<s:property value="page.startIndex" />
						-
						<s:property value="page.endIndex" />
						,
						<s:property value="page.pageNo" />
						/
						<s:property value="page.totalPageNum" />
						Page |
						<s:if test="page.pageNo>1">
							<span class="linkspan" onclick="doQuery(1)">First</span>&nbsp;
	           </s:if>
						<s:if test="page.prePage">
							<span class="linkspan"
								onclick="doQuery(<s:property value="page.pageNo-1"/>)">Previous</span>&nbsp;
	           </s:if>
						<s:if test="page.nextPage">
							<span class="linkspan"
								onclick="doQuery(<s:property value="page.pageNo+1"/>)">Next</span>&nbsp;
	           </s:if>
						<s:if test="page.pageNo!=page.totalPageNum">
							<span class="linkspan"
								onclick="doQuery(<s:property value="page.totalPageNum"/>)">Last</span>&nbsp;
	           </s:if>
						| <input type="text" id="appendedInputButton" class="span1"
							onkeypress="onlynumber();">
						<button class="btn"
							onclick="doQuery($('#appendedInputButton').val());">Go</button>

					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="<c:url value="/js/jquery-1.9.1.min.js"></c:url>"></script>
	<script src="<c:url value="/js/bootstrap.min.js"></c:url>"></script>
	<script type="text/javascript">
	function doQuery(pageno){
		if(pageno<1 || pageno><s:property value="page.totalPageNum"/>){
			alert("Valid page from: 1-<s:property value="page.totalPageNum"/>");
			$('appendedInputButton').select();
              return;
		}
		var f=document.forms[0];
            f.action=f.action+"?page.pageNo="+pageno;
            f.submit();
	}
	
	function read(msgid){
		location.href='<s:url namespace="/security" action="readMsgAction"/>?msg.msg_ID='+msgid;
	};
	
</script>
</body>
</html>